<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "adodb" . EW_PATH_DELIMITER . "adodb.inc.php" ?>
<?php include "phpfn7.php" ?>
<?php include "recibosinfo.php" ?>
<?php include "usuariosinfo.php" ?>
<?php include "cuotasCreditoinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$recibos_view = new crecibos_view();
$Page =& $recibos_view;

// Page init
$recibos_view->Page_Init();

// Page main
$recibos_view->Page_Main();
?>
<?php include "header.php" ?>
<?php if ($recibos->Export == "") { ?>
<script type="text/javascript">
<!--

// Create page object
var recibos_view = new ew_Page("recibos_view");

// page properties
recibos_view.PageID = "view"; // page ID
recibos_view.FormID = "frecibosview"; // form ID
var EW_PAGE_ID = recibos_view.PageID; // for backward compatibility

// extend page with Form_CustomValidate function
recibos_view.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
recibos_view.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
recibos_view.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<?php } ?>
<p><span class="phpmaker"><?php echo $Language->Phrase("View") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $recibos->TableCaption() ?>
<br><br>
<?php if ($recibos->Export == "") { ?>
<a href="<?php echo $recibos_view->ListUrl ?>"><?php echo $Language->Phrase("BackToList") ?></a>&nbsp;
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $recibos_view->AddUrl ?>"><?php echo $Language->Phrase("ViewPageAddLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $recibos_view->EditUrl ?>"><?php echo $Language->Phrase("ViewPageEditLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $recibos_view->CopyUrl ?>"><?php echo $Language->Phrase("ViewPageCopyLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $recibos_view->DeleteUrl ?>"><?php echo $Language->Phrase("ViewPageDeleteLink") ?></a>&nbsp;
<?php } ?>
<?php } ?>
</span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$recibos_view->ShowMessage();
?>
<p>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($recibos->Id->Visible) { // Id ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->Id->FldCaption() ?></td>
		<td<?php echo $recibos->Id->CellAttributes() ?>>
<div<?php echo $recibos->Id->ViewAttributes() ?>><?php echo $recibos->Id->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($recibos->credito->Visible) { // credito ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->credito->FldCaption() ?></td>
		<td<?php echo $recibos->credito->CellAttributes() ?>>
<div<?php echo $recibos->credito->ViewAttributes() ?>><?php echo $recibos->credito->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($recibos->cuota->Visible) { // cuota ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->cuota->FldCaption() ?></td>
		<td<?php echo $recibos->cuota->CellAttributes() ?>>
<div<?php echo $recibos->cuota->ViewAttributes() ?>><?php echo $recibos->cuota->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($recibos->fecha->Visible) { // fecha ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->fecha->FldCaption() ?></td>
		<td<?php echo $recibos->fecha->CellAttributes() ?>>
<div<?php echo $recibos->fecha->ViewAttributes() ?>><?php echo $recibos->fecha->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($recibos->punitorios->Visible) { // punitorios ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->punitorios->FldCaption() ?></td>
		<td<?php echo $recibos->punitorios->CellAttributes() ?>>
<div<?php echo $recibos->punitorios->ViewAttributes() ?>><?php echo $recibos->punitorios->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($recibos->pagado->Visible) { // pagado ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->pagado->FldCaption() ?></td>
		<td<?php echo $recibos->pagado->CellAttributes() ?>>
<div<?php echo $recibos->pagado->ViewAttributes() ?>><?php echo $recibos->pagado->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($recibos->usuario->Visible) { // usuario ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->usuario->FldCaption() ?></td>
		<td<?php echo $recibos->usuario->CellAttributes() ?>>
<div<?php echo $recibos->usuario->ViewAttributes() ?>><?php echo $recibos->usuario->ViewValue ?></div></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<?php if ($recibos->Export == "") { ?>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php } ?>
<?php include "footer.php" ?>
<?php
$recibos_view->Page_Terminate();
?>
<?php

//
// Page class
//
class crecibos_view {

	// Page ID
	var $PageID = 'view';

	// Table name
	var $TableName = 'recibos';

	// Page object name
	var $PageObjName = 'recibos_view';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $recibos;
		if ($recibos->UseTokenInUrl) $PageUrl .= "t=" . $recibos->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $recibos;
		if ($recibos->UseTokenInUrl) {
			if ($objForm)
				return ($recibos->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($recibos->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function crecibos_view() {
		global $conn, $Language;

		// Language object
		$Language = new cLanguage();

		// Table object (recibos)
		$GLOBALS["recibos"] = new crecibos();

		// Table object (usuarios)
		$GLOBALS['usuarios'] = new cusuarios();

		// Table object (cuotasCredito)
		$GLOBALS['cuotasCredito'] = new ccuotasCredito();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'view', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'recibos', TRUE);

		// Start timer
		$GLOBALS["gsTimer"] = new cTimer();

		// Open connection
		$conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $recibos;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $lDisplayRecs = 1;
	var $lStartRec;
	var $lStopRec;
	var $lTotalRecs = 0;
	var $lRecRange = 10;
	var $lRecCnt;
	var $arRecKey = array();

	//
	// Page main
	//
	function Page_Main() {
		global $Language, $recibos;
		$sReturnUrl = "";
		$bMatchRecord = FALSE;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET["Id"] <> "") {
				$recibos->Id->setQueryStringValue($_GET["Id"]);
				$this->arRecKey["Id"] = $recibos->Id->QueryStringValue;
			} else {
				$sReturnUrl = "reciboslist.php"; // Return to list
			}

			// Get action
			$recibos->CurrentAction = "I"; // Display form
			switch ($recibos->CurrentAction) {
				case "I": // Get a record to display
					if (!$this->LoadRow()) { // Load record based on key
						$this->setMessage($Language->Phrase("NoRecord")); // Set no record message
						$sReturnUrl = "reciboslist.php"; // No matching record, return to list
					}
			}
		} else {
			$sReturnUrl = "reciboslist.php"; // Not page request, return to list
		}
		if ($sReturnUrl <> "")
			$this->Page_Terminate($sReturnUrl);

		// Render row
		$recibos->RowType = EW_ROWTYPE_VIEW;
		$this->RenderRow();
	}

	// Set up starting record parameters
	function SetUpStartRec() {
		global $recibos;
		if ($this->lDisplayRecs == 0)
			return;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
				$this->lStartRec = $_GET[EW_TABLE_START_REC];
				$recibos->setStartRecordNumber($this->lStartRec);
			} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
				$this->nPageNo = $_GET[EW_TABLE_PAGE_NO];
				if (is_numeric($this->nPageNo)) {
					$this->lStartRec = ($this->nPageNo-1)*$this->lDisplayRecs+1;
					if ($this->lStartRec <= 0) {
						$this->lStartRec = 1;
					} elseif ($this->lStartRec >= intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1) {
						$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1;
					}
					$recibos->setStartRecordNumber($this->lStartRec);
				}
			}
		}
		$this->lStartRec = $recibos->getStartRecordNumber();

		// Check if correct start record counter
		if (!is_numeric($this->lStartRec) || $this->lStartRec == "") { // Avoid invalid start record counter
			$this->lStartRec = 1; // Reset start record counter
			$recibos->setStartRecordNumber($this->lStartRec);
		} elseif (intval($this->lStartRec) > intval($this->lTotalRecs)) { // Avoid starting record > total records
			$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to last page first record
			$recibos->setStartRecordNumber($this->lStartRec);
		} elseif (($this->lStartRec-1) % $this->lDisplayRecs <> 0) {
			$this->lStartRec = intval(($this->lStartRec-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to page boundary
			$recibos->setStartRecordNumber($this->lStartRec);
		}
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $recibos;
		$sFilter = $recibos->KeyFilter();

		// Call Row Selecting event
		$recibos->Row_Selecting($sFilter);

		// Load SQL based on filter
		$recibos->CurrentFilter = $sFilter;
		$sSql = $recibos->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$recibos->Row_Selected($rs);
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $recibos;
		$recibos->Id->setDbValue($rs->fields('Id'));
		$recibos->credito->setDbValue($rs->fields('credito'));
		$recibos->cuota->setDbValue($rs->fields('cuota'));
		$recibos->fecha->setDbValue($rs->fields('fecha'));
		$recibos->punitorios->setDbValue($rs->fields('punitorios'));
		$recibos->pagado->setDbValue($rs->fields('pagado'));
		$recibos->usuario->setDbValue($rs->fields('usuario'));
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language, $recibos;

		// Initialize URLs
		$this->ExportPrintUrl = $this->PageUrl() . "export=print&" . "Id=" . urlencode($recibos->Id->CurrentValue);
		$this->ExportHtmlUrl = $this->PageUrl() . "export=html&" . "Id=" . urlencode($recibos->Id->CurrentValue);
		$this->ExportExcelUrl = $this->PageUrl() . "export=excel&" . "Id=" . urlencode($recibos->Id->CurrentValue);
		$this->ExportWordUrl = $this->PageUrl() . "export=word&" . "Id=" . urlencode($recibos->Id->CurrentValue);
		$this->ExportXmlUrl = $this->PageUrl() . "export=xml&" . "Id=" . urlencode($recibos->Id->CurrentValue);
		$this->ExportCsvUrl = $this->PageUrl() . "export=csv&" . "Id=" . urlencode($recibos->Id->CurrentValue);
		$this->AddUrl = $recibos->AddUrl();
		$this->EditUrl = $recibos->EditUrl();
		$this->CopyUrl = $recibos->CopyUrl();
		$this->DeleteUrl = $recibos->DeleteUrl();
		$this->ListUrl = $recibos->ListUrl();

		// Call Row_Rendering event
		$recibos->Row_Rendering();

		// Common render codes for all row types
		// Id

		$recibos->Id->CellCssStyle = ""; $recibos->Id->CellCssClass = "";
		$recibos->Id->CellAttrs = array(); $recibos->Id->ViewAttrs = array(); $recibos->Id->EditAttrs = array();

		// credito
		$recibos->credito->CellCssStyle = ""; $recibos->credito->CellCssClass = "";
		$recibos->credito->CellAttrs = array(); $recibos->credito->ViewAttrs = array(); $recibos->credito->EditAttrs = array();

		// cuota
		$recibos->cuota->CellCssStyle = ""; $recibos->cuota->CellCssClass = "";
		$recibos->cuota->CellAttrs = array(); $recibos->cuota->ViewAttrs = array(); $recibos->cuota->EditAttrs = array();

		// fecha
		$recibos->fecha->CellCssStyle = ""; $recibos->fecha->CellCssClass = "";
		$recibos->fecha->CellAttrs = array(); $recibos->fecha->ViewAttrs = array(); $recibos->fecha->EditAttrs = array();

		// punitorios
		$recibos->punitorios->CellCssStyle = ""; $recibos->punitorios->CellCssClass = "";
		$recibos->punitorios->CellAttrs = array(); $recibos->punitorios->ViewAttrs = array(); $recibos->punitorios->EditAttrs = array();

		// pagado
		$recibos->pagado->CellCssStyle = ""; $recibos->pagado->CellCssClass = "";
		$recibos->pagado->CellAttrs = array(); $recibos->pagado->ViewAttrs = array(); $recibos->pagado->EditAttrs = array();

		// usuario
		$recibos->usuario->CellCssStyle = ""; $recibos->usuario->CellCssClass = "";
		$recibos->usuario->CellAttrs = array(); $recibos->usuario->ViewAttrs = array(); $recibos->usuario->EditAttrs = array();
		if ($recibos->RowType == EW_ROWTYPE_VIEW) { // View row

			// Id
			$recibos->Id->ViewValue = $recibos->Id->CurrentValue;
			$recibos->Id->CssStyle = "";
			$recibos->Id->CssClass = "";
			$recibos->Id->ViewCustomAttributes = "";

			// credito
			$recibos->credito->ViewValue = $recibos->credito->CurrentValue;
			$recibos->credito->CssStyle = "";
			$recibos->credito->CssClass = "";
			$recibos->credito->ViewCustomAttributes = "";

			// cuota
			$recibos->cuota->ViewValue = $recibos->cuota->CurrentValue;
			$recibos->cuota->CssStyle = "";
			$recibos->cuota->CssClass = "";
			$recibos->cuota->ViewCustomAttributes = "";

			// fecha
			$recibos->fecha->ViewValue = $recibos->fecha->CurrentValue;
			$recibos->fecha->CssStyle = "";
			$recibos->fecha->CssClass = "";
			$recibos->fecha->ViewCustomAttributes = "";

			// punitorios
			$recibos->punitorios->ViewValue = $recibos->punitorios->CurrentValue;
			$recibos->punitorios->CssStyle = "";
			$recibos->punitorios->CssClass = "";
			$recibos->punitorios->ViewCustomAttributes = "";

			// pagado
			$recibos->pagado->ViewValue = $recibos->pagado->CurrentValue;
			$recibos->pagado->CssStyle = "";
			$recibos->pagado->CssClass = "";
			$recibos->pagado->ViewCustomAttributes = "";

			// usuario
			$recibos->usuario->ViewValue = $recibos->usuario->CurrentValue;
			$recibos->usuario->CssStyle = "";
			$recibos->usuario->CssClass = "";
			$recibos->usuario->ViewCustomAttributes = "";

			// Id
			$recibos->Id->HrefValue = "";
			$recibos->Id->TooltipValue = "";

			// credito
			$recibos->credito->HrefValue = "";
			$recibos->credito->TooltipValue = "";

			// cuota
			$recibos->cuota->HrefValue = "";
			$recibos->cuota->TooltipValue = "";

			// fecha
			$recibos->fecha->HrefValue = "";
			$recibos->fecha->TooltipValue = "";

			// punitorios
			$recibos->punitorios->HrefValue = "";
			$recibos->punitorios->TooltipValue = "";

			// pagado
			$recibos->pagado->HrefValue = "";
			$recibos->pagado->TooltipValue = "";

			// usuario
			$recibos->usuario->HrefValue = "";
			$recibos->usuario->TooltipValue = "";
		}

		// Call Row Rendered event
		if ($recibos->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$recibos->Row_Rendered();
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	function Message_Showing(&$msg) {

		// Example:
		//$msg = "your new message";

	}
}
?>
